home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00092_Script_PAGES < prev    next >
Text File  |  1996-03-28  |  7KB  |  228 lines

  1. -- --------------------------------------------------------------
  2. -- Handler showPage shows the next page of the text in the given
  3. -- direction.
  4.  
  5. on showPage direction
  6.   global textSprite
  7.   
  8.   set the editableText of sprite textSprite = FALSE
  9.   set nextPageCastNumber = getNextPageCast(direction)
  10.   set the castNum of sprite textSprite = nextPageCastNumber
  11.   setTopicTextAttributes(nextPageCastNumber)
  12.   
  13.   updateCurrentPage(direction)
  14.   
  15.   showMoreButtons
  16.   updateStage
  17. end
  18.  
  19. -- --------------------------------------------------------------
  20. -- Handler resetCurrentPage resets the global variable currentPage
  21. -- to 1. This global variable is used to indicate the page number
  22. -- of the currently displayed page of text (to know what page
  23. -- number the previous and next pages are for pageUp and pageDown).
  24.  
  25. on resetCurrentPage
  26.   global currentPage
  27.   
  28.   set currentPage = 1
  29. end
  30.  
  31. -- --------------------------------------------------------------
  32. -- Handler updateCurrentPage sets the global variable currentPage
  33. -- to the next page in the given direction.
  34.  
  35. on updateCurrentPage direction
  36.   global currentPage
  37.   
  38.   set currentPage = currentPage + direction
  39. end
  40.  
  41. -- --------------------------------------------------------------
  42. -- Handler setCurrentPage sets the global variable currentPage
  43. -- to the page number of the current topic text.
  44.  
  45. on setCurrentPage -- called from journeyClick
  46.   global currentPage, textSprite
  47.   
  48.   set currentPage = value(the last char of the name of cast the castNum of sprite textSprite)
  49. end
  50.  
  51. -- --------------------------------------------------------------
  52. -- Handler getNextPageCast returns the cast number of the next page
  53. -- if the current topic has more pages and -1 otherwise.
  54.  
  55. on getNextPageCast direction
  56.   global textSprite, currentPage
  57.   
  58.   waitCursor
  59.   
  60.   set castNumber = getTextCastNumber(clickedTopic, currentPage + direction)
  61.   normalCursor
  62.   
  63.   return castNumber
  64. end
  65.  
  66. -- --------------------------------------------------------------
  67. -- Handler showMoreButtons shows the up and down arrows if more
  68. -- pages exist.
  69.  
  70. on showMoreButtons
  71.   global pageUpButton, pageDownButton, topicProperty
  72.   
  73.   if (topicProperty = "text") then
  74.     if morePagesExist(-1) then -- pages up
  75.       set upStatus = 1
  76.     else
  77.       set upStatus = 0
  78.     end if
  79.     
  80.     if morePagesExist(1) then -- pages down
  81.       set downStatus = 1
  82.     else
  83.       set downStatus = 0
  84.     end if
  85.   else if (topicProperty = "picture") then
  86.     if morePicturesExist(-1) then -- pages up
  87.       set upStatus = 1
  88.     else
  89.       set upStatus = 0
  90.     end if
  91.     
  92.     if morePicturesExist(1) then -- pages down
  93.       set downStatus = 1
  94.     else
  95.       set downStatus = 0
  96.     end if
  97.   end if
  98.   
  99.   if (upStatus and DownStatus) then
  100.     showPageUpButton("Enabled")
  101.     showPageDownButton("Enabled")
  102.     setButtonCursor (1, pageUpButton)
  103.     setButtonCursor (1, pageDownButton)
  104.   end if
  105.   
  106.   if (upstatus and not(downStatus)) then
  107.     showPageUpButton("Enabled")
  108.     showPageDownButton("Disabled")
  109.     setButtonCursor (1, pageUpButton)
  110.     setButtonCursor (0, pageDownButton)
  111.   end if
  112.   
  113.   if (not(upstatus) and downStatus) then
  114.     showPageDownButton("Enabled")
  115.     showPageUpButton("Disabled")
  116.     setButtonCursor (0, pageUpButton)
  117.     setButtonCursor (1, pageDownButton)
  118.   end if
  119.   
  120.   if (not(upstatus) and not(downStatus)) then
  121.     removeMoreButtons
  122.     setButtonCursor (0, pageUpButton)
  123.     setButtonCursor (0, pageDownButton)
  124.   end if
  125. end
  126.  
  127. -- --------------------------------------------------------------
  128. -- Handler removeMoreButtons removes from the screen the up and
  129. -- down arrows that indicate more pages.
  130.  
  131. on removeMoreButtons
  132.   global pageUpButton, pageDownButton
  133.   
  134.   removeFromStage(pageUpButton)
  135.   removeFromStage(pageDownButton)
  136. end
  137.  
  138. -- --------------------------------------------------------------
  139. -- Handler morePagesExist returns TRUE if there are more pages
  140. -- in the given direction (-1 = page up, 1 = page down) and FALSE
  141. -- otherwise.
  142.  
  143. on morePagesExist direction
  144.   global numPagesInClickedTopic, currentPage
  145.   
  146.   if ((direction = 1) and (currentPage < numPagesInClickedTopic)) or ((direction = -1) and (currentPage <> 1)) then
  147.     return TRUE
  148.   else
  149.     return FALSE
  150.   end if
  151. end
  152.  
  153. -- --------------------------------------------------------------
  154. -- Handler showPageUpButton shows the page up button.
  155.  
  156. on showPageUpButton status
  157.   global pageUpButton, pageUpH, pageUpV
  158.   
  159.   changeButtonCast pageUpButton, status
  160.   set the locH of sprite pageUpButton = pageUpH
  161.   set the locV of sprite pageUpButton = pageUpV
  162. end
  163.  
  164. -- --------------------------------------------------------------
  165. -- Handler showPageDownButton shows the page down button.
  166.  
  167. on showPageDownButton status
  168.   global pageDownButton, pageDownH, pageDownV
  169.   
  170.   changeButtonCast pageDownButton, status
  171.   set the locH of sprite pageDownButton = pageDownH
  172.   set the locV of sprite pageDownButton = pageDownV
  173. end
  174.  
  175. -- --------------------------------------------------------------
  176. -- Handler setNumPagesInClickedTopic sets the global variable
  177. -- numPagesInClickedTopic to the number of pages in the article 
  178. -- of the clicked topic.
  179.  
  180. on setNumPagesInClickedTopic
  181.   global numPagesInClickedTopic, numPagesAll, clickedTopic
  182.   
  183.   set the itemDelimiter = ":"
  184.   set theLine = binSearchFirstItemInLine(numPagesAll, clickedTopic, ":")
  185.   
  186.   if (theLine = 0) then
  187.     alert clickedTopic && "is not in field numPages per Topic"
  188.   else
  189.     set numPagesInClickedTopic = item 2 of line theLine of numPagesAll
  190.   end if
  191.   set the itemDelimiter = ","
  192. end
  193.  
  194. -- --------------------------------------------------------------
  195. -- Handler morePicturesExist returns TRUE if there are more pictures
  196. -- in the given direction (-1 = page up, 1 = page down) and FALSE
  197. -- otherwise.
  198.  
  199. on morePicturesExist direction
  200.   global numPicturesInClickedTopic, currentPicture
  201.   
  202.   if ((direction = 1) and (currentPicture < numPicturesInClickedTopic)) or ((direction = -1) and (currentPicture <> 1)) then
  203.     return TRUE
  204.   else
  205.     return FALSE
  206.   end if
  207. end
  208.  
  209. -- --------------------------------------------------------------
  210. -- Handler setNumPicturesInClickedTopic sets the global variable
  211. -- numPicturesInClickedTopic to the number of pictures in
  212. -- the clicked topic.
  213.  
  214. on setNumPicturesInClickedTopic
  215.   global numPicturesInClickedTopic, numPicturesAll, clickedTopic
  216.   
  217.   set the itemDelimiter = ":"
  218.   set theLine = binSearchFirstItemInLine(numPicturesAll, clickedTopic, ":")
  219.   
  220.   if (theLine = 0) then
  221.     alert clickedTopic && "is not in field numPictures per Topic"
  222.   else
  223.     set numPicturesInClickedTopic = item 2 of line theLine of numPicturesAll
  224.   end if
  225.   set the itemDelimiter = ","
  226. end
  227.  
  228.